﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


class QueryUtil
{
    public static string FormatValue(Object someValue)
    {
        string FormattedValue = "";
        if (someValue == null)
        {
            FormattedValue = "NULL";
        }
        else
        {
            switch (someValue.GetType().Name)
            {
                case "String": FormattedValue = "'" + ((string)someValue).Replace("'", "''") + "'"; break;
                case "Guid": FormattedValue = "'" + someValue.ToString() + "'"; break;
                case "DateTime": FormattedValue = "'" + ((DateTime)someValue).ToString("yyyy/MM/dd hh:mm:ss") + "'"; break;
                case "DBNull": FormattedValue = "NULL"; break;
                case "Boolean": FormattedValue = (bool)someValue ? "1" : "0"; break;
               // case "SqlLiteral": FormattedValue = ((SqlLiteral)someValue).Value; break;
                default: FormattedValue = someValue.ToString(); break;
            }
        }
        return FormattedValue;
    }
}

